#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QLineEdit>
#include <QLabel>
#include <QPushButton>
#include <QTextEdit>
#include <QGroupBox>
#include <QComboBox>
#include <QCheckBox>
#include <QSpinBox>
#include "simplekeyboard.h"

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

protected:
    bool eventFilter(QObject *obj, QEvent *event) override;

private slots:
    void onInputFocused();
    void onKeyboardModeChanged(TouchKeyboard::KeyboardMode mode);
    void onKeyboardHidden();
    void onTestButtonClicked();
    void onClearAllClicked();

private:
    void setupUI();
    void createInputFields();
    void createControlPanel();
    void setupKeyboard();
    void setupConnections();
    
    // UI组件
    QWidget *m_centralWidget;
    QVBoxLayout *m_mainLayout;
    
    // 输入字段组
    QGroupBox *m_inputGroup;
    QGridLayout *m_inputLayout;
    QLineEdit *m_nameEdit;
    QLineEdit *m_ageEdit;
    QLineEdit *m_phoneEdit;
    QLineEdit *m_emailEdit;
    QLineEdit *m_addressEdit;
    QLineEdit *m_calculatorEdit;
    QTextEdit *m_notesEdit;
    
    // 控制面板
    QGroupBox *m_controlGroup;
    QHBoxLayout *m_controlLayout;
    QPushButton *m_testButton;
    QPushButton *m_clearButton;
    QComboBox *m_modeCombo;
    QCheckBox *m_autoShowCheck;
    
    // 状态显示
    QLabel *m_statusLabel;
    
    // 键盘
    SimpleKeyboard *m_keyboard;
    QLineEdit *m_currentInput;
    
    // 设置
    bool m_autoShowKeyboard;
};

#endif // MAINWINDOW_H